package com.wawayaya.bookreader.bean;


public class TimeRangeKey implements Comparable<TimeRangeKey>, java.io.Serializable{

	private static final long serialVersionUID = 1L;

	private int m_itimebegin;
	private int m_itimeend;
	
	public TimeRangeKey(int iitimebegin, int itimeend) {
		m_itimebegin = iitimebegin;
		m_itimeend = itimeend;
	}

	public TimeRangeKey(IntDouble idu) {
		if(null != idu) {
			m_itimebegin = idu.m_ival1;
			m_itimeend = idu.m_ival2;
		}
	}
	
	public TimeRangeKey(TimeRangeKey obj) {
		if(null != obj) {
			m_itimebegin = obj.m_itimebegin;
			m_itimeend = obj.m_itimebegin;
		}
	}
	
	public int gettimebegin() {
		return m_itimebegin;
	}
	
	public int gettimeend() {
		return m_itimeend;
	}
	
	@Override
	public int compareTo(TimeRangeKey obj) {
		if(null == obj) {
			return 1;
		}
		if(obj.m_itimebegin >= m_itimebegin && obj.m_itimeend <= m_itimeend) {
			return 0;
		}
		if(obj.m_itimebegin >= m_itimeend) {
			return -1;
		}
		if(obj.m_itimeend <= m_itimebegin){
			return 1;
		}
		if(obj.m_itimebegin < m_itimebegin && obj.m_itimeend > m_itimeend) {
			return 0;
		}
		if(obj.m_itimebegin < m_itimebegin && obj.m_itimeend < m_itimeend) {
			return 1;
		}
		return -1;
	}

}
